<?php
define('FATE_DEBUG', true);
define('VENDOR_PATH', __DIR__ . '/../vendor');
// 静态资源路径
define('RES', '/dist');

// 框架
include __DIR__ . '/../vendor/afuafuyo/fatephp/Fate.php';
include __DIR__ . '/../vendor/autoload.php';

// 核心配置
include __DIR__ . '/../app/libs/IniReader.php';
include __DIR__ . '/../core/main.php';

if('' === $main['securityKey']) {
    echo 'The securityKey config must set';
    exit;
}

// start
$iniReader = new \IniReader(__DIR__ . '/../core/configuration.ini');
$_G = [];
$_G['now_time'] = isset($_SERVER['REQUEST_TIME']) ? $_SERVER['REQUEST_TIME'] : time();
$_G['theme'] = $iniReader->get('system', 'theme');
Fate::setPathAlias('@themes', __DIR__ . '/../app/themes/' . $_G['theme']);

// 入口
$appConf = array_merge($main, [
    'iniReader' => $iniReader,
    'appPath' => __DIR__ . '/../app',
    'layout' => Fate::getPathAlias('@themes') .'/layout.php',
    'errorHandler' => 'app\ErrorPage',
    'modules' => [
        'admin' => 'app\modules\admin',
        'adminapi' => 'app\modules\adminapi',
    ]
]);

(new \fate\web\Application($appConf))->run();
